<template>
  <!-- 轮播图组件 -->
  <view class="com-banner">
    <view v-if="isEmpty" class="swiper">
      <view class="swiper-item">
        <image src="@/static/images/image_empty2.png" mode="aspectFill" class="image" />
      </view>
    </view>
    <swiper v-else interval="3000" indicator-dots autoplay circular indicator-color="rgba(255,255,255,0.3)"
      indicator-active-color="#F6C6CE" class="swiper">
      <swiper-item v-for="item in dataList" :key="item?._id" @click="goItem" :data-item="item" class="swiper-item">
        <image :src="item?.picurl" mode="aspectFill" class="image" />
      </swiper-item>
    </swiper>
  </view>
</template>


<script lang="ts" setup>
const props = defineProps({
  dataList: {
    type: Array as any,
    default: () => []
  },
  isEmpty: {
    type: Boolean,
    default: true
  },
});

const goItem = (e: any) => {
  let item = e.currentTarget.dataset.item;
  console.log("~~~", item);

  if (item.target === "self") {
    uni.navigateTo({
      url: `/pages/pkgB/typeList/index?${item.url}`
    })
    return;
  }

  if (item.target === "miniProgram") {
    uni.navigateToMiniProgram({
      appId: item.appid,
      path: item.url ?? ''
    })
    return;
  }
};
</script>


<style lang="scss" scoped>
@use "style.scss";
</style>